//////////////////////////////////////////////////////////////////////////////////////////////
//	File			:	"BattleReportState.cpp"
//
//	Author			:	Mike Davis, Matt Stover, James Thornton, Keith Webster
//	
//	Project			:	TacWars
//
//	Last Modified	:	11/6/2013
//
//	Purpose			:	
//
//////////////////////////////////////////////////////////////////////////////////////////////

#include "BattleReportState.h"
#include "../../SGD Wrappers/CSGD_Direct3D.h"
#include "../../SGD Wrappers/CSGD_DirectInput.h"
#include "../../SGD Wrappers/CSGD_TextureManager.h"
#include "../../SGD Wrappers/CSGD_XAudio2.h"
#include "../../SGD Wrappers/CSGD_MessageSystem.h"
#include "../../SGD Wrappers/CSGD_EventSystem.h"
#include "../../SGD Wrappers/SGD_String.h"
#include "../../SGD Wrappers/SGD_Math.h"
#include "GameplayState.h"
#include "../Game.h"
#include <cassert>

BattleReportState* BattleReportState::GetInstance()
{
	static BattleReportState Instance;

	return &Instance;
}
BattleReportState::BattleReportState()
{
	cursor = 0;
}
BattleReportState::~BattleReportState()
{
}
/*virtual*/ void BattleReportState::Enter()
{
	titleImgID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("resource/Images/MapStage3.png"));
}
/*virtual*/ void BattleReportState::Exit()
{

}
/*virtual*/ bool BattleReportState::Input()
{
	CSGD_DirectInput* DI = CSGD_DirectInput::GetInstance();

	if(DI->JoystickIsUnplugged())
	{
		if(DI->KeyPressed(DIK_RETURN) == true || DI->KeyPressed(DIK_ESCAPE) == true)
		{
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
		}
	}
	else
	{
		if(DI->JoystickButtonPressed(1) == true || DI->JoystickButtonPressed(0) == true)
		{
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
		}
	}
	return true;
}
/*virtual*/ void BattleReportState::Update( float fElapsedTime )
{

}
/*virtual*/ void BattleReportState::Render()
{
	BitmapFont* Font = Game::GetInstance()->GetFont();
	CSGD_TextureManager::GetInstance()->Draw(titleImgID, 0, 0, 1.0f, 1.0f);

	TOSTRINGSTREAM report;
	report << (9 - GameplayState::GetInstance()->player1->Squad.size());

	Font->Draw( _T("BATTLE REPORT"), (int)((640 - (4*64*2.0f)) / 2), 
		50, 2.0f, D3DCOLOR_ARGB(255, 255, 255, 255) );


	Font->Draw( _T("UNITS LOST"), (340 - (4*64)) / 2, 200, 1.0f, D3DCOLOR_ARGB(255, 255, 255, 255) );
	Font->Draw(report.str().c_str(), (1440 - (4*64)) / 2, 200, 1.0f, D3DCOLOR_ARGB(255,255,255,255));

	//report.str(_T(""));
	//if( (GameplayState::GetInstance()->player1->Squad.size() - 9) < 0)
		report << 0;
	//else if( (GameplayState::GetInstance()->player1->Squad.size() - 9) > 0)
	//	report << GameplayState::GetInstance()->player1->Squad.size() - 9;

	Font->Draw( _T("UNITS RECRUITED"), (340 - (4*64)) / 2, 300, 1.0f, D3DCOLOR_ARGB(255,255,255,255));
	Font->Draw( report.str().c_str(), (1440 - (4*64)) / 2, 300, 1.0f, D3DCOLOR_ARGB(255,255,255,255));

	report.str(_T(""));
	//powerNodeCapCount or something
	Font->Draw( _T("POWER NODES CAPTURED"), (340 - (4*64)) /2, 400, 1.0f, D3DCOLOR_ARGB(255,255,255,255));
	Font->Draw( _T("0"), (1440 - (4*64)) / 2, 400, 1.0f, D3DCOLOR_ARGB(255,255,255,255));


	Font->Draw(_T("OK"), (800-(4*32)) / 2, 500, 1.0f, D3DCOLOR_ARGB(255,255,255,255));
	//Font->Draw( _T("(     )"), (500 - (7*32)) / 2, 500, 1.0f, D3DCOLOR_ARGB(255, 255, 255, 255) );

}
